package common.globol;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Properties;

public class Config {
    public static Config getConfig() {
        return Config.ConfigHolder.INSTANCE.getConfig();
    }

    private static enum ConfigHolder{
        INSTANCE;

        private Config config;

        private ConfigHolder(){
            config=new Config();
            config.getPro();
        }

        public Config getConfig(){
            return config;
        }
    }

    private void getPro(){
        pro= new Properties();
        try {
            pro.load(this.getClass().getResourceAsStream(porFiles[0]));
            shenhua_token=pro.getProperty("token");
            pro.load(this.getClass().getResourceAsStream(porFiles[1]));
            android_appName=pro.getProperty("appName");
            android_deviceName=pro.getProperty("deviceName");
            android_platformVersion=pro.getProperty("platformVersion");
            android_appPackage=pro.getProperty("appPackage");
            android_appActivity=pro.getProperty("appActivity");
            pro.load(this.getClass().getResourceAsStream(porFiles[2]));
            firefoxPath=pro.getProperty("firefoxPath");
            iePath=pro.getProperty("iePath");
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    private String[] porFiles=new String[]{
            "/shenhua.properties",
            "/android.properties",
            "/web.properties",
    };
    private Properties pro;
    private String shenhua_token;
    private String android_appName;
    private String android_deviceName;
    private String android_platformVersion;
    private String android_appPackage;
    private String android_appActivity;
    private String firefoxPath;
    private String iePath;


    public String getShenhua_token() {
        return shenhua_token;
    }

    public String getAndroid_appName() {
        return android_appName;
    }

    public String getAndroid_deviceName() {
        return android_deviceName;
    }

    public String getAndroid_platformVersion() {
        return android_platformVersion;
    }

    public String getAndroid_appPackage() {
        return android_appPackage;
    }

    public String getAndroid_appActivity() {
        return android_appActivity;
    }

    public String getFirefoxPath() {
        return firefoxPath;
    }

    public String getIePath() {
        return iePath;
    }
}
